package com.by.controller;

import com.by.bean.Order.Order;
import com.by.bean.OrderLog;
import com.by.bean.OrderQueryCriteria;
import com.by.common.core.bean.PageBean;
import com.by.common.core.bean.ResultBean;
import com.by.common.core.controller.BaseController;
import com.by.remote.system.Order.QueryOrderByCode;
import com.by.service.OrderService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;


@RestController
@RequestMapping("/order")
@Api(tags = "订单管理")
@Slf4j
public class OrderController extends BaseController implements QueryOrderByCode {

    @Autowired
    OrderService orderService;

    @PostMapping("/query")
    @ApiOperation("查询订单列表")
    public ResultBean<PageBean> queryOrderList(@RequestBody OrderQueryCriteria orderQueryCriteria){
        PageBean pageBean = orderService.queryOrderList(orderQueryCriteria);
        return success("订单列表",pageBean);
    }

    @GetMapping("/query/log")
    @ApiOperation("查询订单日志")
    public ResultBean<List<Map>> queryOrderLog(String orderSn){
        List<OrderLog> list = orderService.queryOrderLog(orderSn);
        return success("订单日志",list);
    }


    @Override
    public Order queryOrderByCode(String code) {
        Order order =orderService.queryOrderByCode(code);
        return order;
    }
}
